home *** CD-ROM | disk | FTP | other *** search
- package SourceList;
-
- require Exporter;
- @ISA = 'Exporter';
- @EXPORT = qw(Sources);
-
- use strict;
-
- # Input file:
- #
- # | Source:
- # | foo.c
- # | Bar:
- # | bar.c
- #
- # Output:
- #
- # [
- # {
- # FILE => 'foo.c',
- # DIR => ':Source:'
- # }, {
- # FILE => 'bar.c',
- # DIR => ':Source:Bar:'
- # }
- # ]
-
- sub Sources {
- local @ARGV = @_;
- my $oldtabs = -1;
- my @path;
- my @SOURCES;
- while (<ARGV>) {
- chop;
- s/^(\t*)//;
- my $tabs = length $1;
-
- if ($tabs > $oldtabs) {
- $tabs - $oldtabs == 1 or die "Too many tabs ($oldtabs -> $tabs)";
- } else {
- $#path -= ($oldtabs - $tabs + 1);
- }
- $oldtabs = $tabs;
- if (!/:$/) {
- my $pathname = join('', ':', @path);
- push @SOURCES, {DIR => $pathname, FILE => $_};
- }
- push @path, $_;
- }
- return \@SOURCES;
- }
-
-